package com.wosaitech.baby.restful;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.http.HttpServletResponse;

import org.springframework.http.HttpHeaders;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.alibaba.fastjson.JSON;
//import java.util.Base64;
import com.wosaitech.baby.entry.User;

@Controller
public class RestFul2 {

	@RequestMapping(method = RequestMethod.GET, value = "/login/{workCode}/{passwd}")
	public void loginOld(@PathVariable String workCode,
			@PathVariable String passwd, HttpServletResponse response,
			@RequestHeader HttpHeaders headers) throws IOException {
		User user = new User();
		user.setLoginName(workCode);
		user.setPassword(passwd);
		JsonResult result = new JsonResult();
		result.setCurRec(1);
		result.setMessage("登录成功");
		result.setObject(user);
		response.addHeader("Access-Control-Allow-Origin", "*");
		response.setCharacterEncoding("utf-8");
		PrintWriter out = response.getWriter();
		out.print(JSON.toJSON(result).toString());
		out.close();
	}

}
